//
//  Extension+UIButton.swift
//  weibo
//
//  Created by apple on 15/12/18.
//  Copyright © 2015年 LYR. All rights reserved.
//

import UIKit

extension UIButton {

    convenience init(title: String,imageName: String?,backImageName: String?,fontSize: CGFloat,color: UIColor ) {
    
        self.init()
        
        if imageName != nil {
        
        setImage(UIImage(named: imageName!), forState: .Normal)
        }
        
        setTitle(title, forState: .Normal)
        
        if backImageName != nil {
            
        setBackgroundImage(UIImage(named: backImageName!), forState: .Normal)
        
        }
        
        setTitleColor(UIColor.blackColor(), forState: .Normal)
        
        titleLabel?.font = UIFont.systemFontOfSize(fontSize)
        
        sizeToFit()
        
    }
    
    convenience init(imageName: String?,backImageName: String) {
        
        self.init()
        
        if imageName != nil {
            
        setImage(UIImage(named: imageName!), forState: .Normal)
        
        setImage(UIImage(named: imageName! + "_highlighted"), forState: .Highlighted)
        
        }
        setBackgroundImage(UIImage(named: backImageName), forState: .Normal)
    
        setBackgroundImage(UIImage(named: backImageName + "_highlighted"), forState: .Highlighted)
    
        sizeToFit()
    
    }
    
    
    

}
